/**
 * 
 */
package spl.army.ut;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import spl.army.Observer;

/**
 * @author avikam
 *
 */
public class ObserverTest {

	/**
	 * @throws Exception
	 */
	@Before
	public void setUp() throws Exception {
	}

	/**
	 * @throws java.lang.Exception
	 */
	@After
	public void tearDown() throws Exception {
	}

	/**
	 * Test method for {@link spl.army.Observer#runCommand(java.lang.String)}.
	 */
	@Test
	public void testRunCommand() {
		assertFalse(Observer.runCommand("addMission blabla"));
		assertTrue(Observer.runCommand("addMission eliminatePrimeMisinster sniper 12, sniperRifle 20 camouflageSuit 20 AK47 20, eliminateChiefofStaff"));
		
		// Mess a little bit with command: no name, no skill, no time
		assertFalse(Observer.runCommand("addMission sniper 12, sniperRifle 20 camouflageSuit 20 AK47 20, eliminateChiefofStaff"));
		assertFalse(Observer.runCommand("addMission eliminatePrimeMisinster 12, sniperRifle 20 camouflageSuit 20 AK47 20, eliminateChiefofStaff"));
		assertFalse(Observer.runCommand("addMission eliminatePrimeMisinster sniper, sniperRifle 20 camouflageSuit 20 AK47 20, eliminateChiefofStaff"));
		
		// Mission with bad items list
		assertFalse(Observer.runCommand("addMission intelegence intel 10, item1"));
		assertFalse(Observer.runCommand("addMission intelegence intel 10, item1 item2"));
		
		assertTrue(Observer.runCommand("addMission intelegence intel 10, item1 10 item2 15"));
		
		// Full mission description
		assertTrue(Observer.runCommand("addMission eliminateChiefofStaff commando 48, AK47 47 sniperRifle 15 camouflageSuit 15 AK47 15 granade 300, destroyAirForces destroyNavy destroyInfantry"));
		assertTrue(Observer.runCommand("addMission breakOnThroughToTheOtherSide AK 47, AK 57 camouflageSuit 1 AK47 20, eliminatePrimeMisinster eliminateNavy"));
		
		// Mission with no dependencies missions
		assertTrue(Observer.runCommand("addMission OhYeh GuitarBase 1, Gibson 5 camouflageSuit 20 AK47 20"));
		
		assertTrue(Observer.runCommand("addSergeant rambo 3 10, sniper commando, 10 shortestMission"));
		assertTrue(Observer.runCommand("addSergeant jackSparo 3 10, sniper commando, 10 longestMission"));
		assertFalse(Observer.runCommand("addSergeant jimMorrison"));
		
		// Sanity test
		assertTrue(Observer.runCommand("addItem sniperRifle 30"));
		// Mess with command
		assertFalse(Observer.runCommand("addItem 30 sniperRifle"));
		
		
		// Some more sanity tests
		assertTrue(Observer.runCommand("stop"));
		assertTrue(Observer.runCommand("completeMissions"));
		assertTrue(Observer.runCommand("incompleteMissions"));
		assertTrue(Observer.runCommand("sergeants"));
		assertTrue(Observer.runCommand("warehouse"));
		assertFalse(Observer.runCommand("no-such-mission"));
	}

}

